import { reqChannel } from '@/api/article'
import type { ChannelsItem } from '@/types/article'
import { useEffect, useState } from 'react'

export const useChannel = () => {
  // 获取频道列表
  const [channelList, setChannelList] = useState<ChannelsItem[]>([])
  const getChannels = async () => {
    const res = await reqChannel()
    setChannelList(res.data.channels)
  }

  useEffect(() => {
    getChannels()
  }, [])

  return {
    channelList
  }
}
